<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue-router/3.2.0/vue-router.min.js"></script>
</head>

<body>
    <!-- 组件模板-->

    <div id="app">
        <my-aaa></my-aaa>
    </div>

    <!-- 模板 -->
    <template id="aaa">
        <div>
            <h1>这是一个模板组件</h1>
            <ul>
                <li v-for="val in arr">{{val}}</li>
            </ul>
        </div>
    </template>

    <script>
        // 创建Vue的对象
        let vm = new Vue({
            el: "#app",
            // 局部组件
            components: {
                'my-aaa': {
                    // 组件中可以有数据、methods 、computed、template
                    data() {
                        return {
                            msg: 'hello components',
                            arr: ['apple', 'banana', 'orange']
                        }
                    },
                    methods: {
                        change() {
                            this.msg = 'changed......'
                        }
                    },
                    template: '#aaa'
                }
            }
        })
    </script>
</body>

</html>